package post

import (
	"github.com/gin-gonic/gin"
	. "myplatform/handler/post"
	"myplatform/middleware"
)

func PostLoad(g *gin.Engine) {
	//使用路由组，创建restful api
	PostV1 := g.Group("api/v1/post") //  /api/v1相当于前缀
	//stuV1.Use(middleware.AuthToken)  //为路由组添加中间件
	{
		//发布新帖子,可能用到token传uid
		PostV1.POST("", middleware.AuthToken, Addpost)
		//删除帖子，根据pid
		PostV1.DELETE("/:id", Delpost)
		//修改帖子，根据pid
		PostV1.PUT("/:id", Uppost)
		//查看所有的帖子
		PostV1.GET("", Getpost)
		//根据关键字查询帖子
		PostV1.GET("/searchkw", GetPostBykey)
		//主页点击帖子展开按钮跳转HTML用到的传入路由
		PostV1.GET("/searchpid", GetPostBypid)
		PostV1.GET("/searchpidHTML", GetPostBypidHTML)
		//点赞
		PostV1.POST("/searchpid/like", middleware.AuthToken, Like)
		//收藏
		PostV1.POST("/searchpid/collect", middleware.AuthToken, Collect)

		//stuV1.GET("/:id", GetStuById)
		//stuV1.GET("/search", GetStuBykey)
	}
	//根据帖子找类型,帖子1号-》1，5，8类型
	g.GET("/post/type", GetTypeBypost)
	//根据帖子找帖主
	g.GET("/post/writer", GetWriterBypost)
	//根据帖子找评论
	g.GET("/post/comment", GetCommentBypost)
	//根据帖子找收藏用户
	g.GET("/post/usercollect", GetUserCollectBypost)

	//图片上传路由
	g.POST("/api/upload", UploadImage)
}
